package com.hisense.ovcloud.warehouse.config;

import com.hisense.ovcloud.commons.configs.validator.BaseValidator;
import com.hisense.ovcloud.warehouse.dto.req.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.validation.Validator;

import java.util.List;

@Configuration
@Order(-999)
public class ValidatorsConfig {

    @Bean
    @Qualifier("activateDeviceReqValidator")
    public Validator activateDeviceReqValidator(){
        return new BaseValidator(ActivateDeviceReq.class, List.of("physicalDeviceId"));
    }

    @Bean
    @Qualifier("authBatchReqValidator")
    public Validator authBatchReqValidator(){
        return new BaseValidator(AuthBatchReq.class, List.of("wifiId"));
    }

    @Bean
    @Qualifier("batchCodeCountReqValidator")
    public Validator batchCodeCountReqValidator(){
        return new BaseValidator(BatchCodeCountReq.class, List.of("batchCode"));
    }

    @Bean
    @Qualifier("cipherWithDKeyReqValidator")
    public Validator cipherWithDKeyReqValidator(){
        return new BaseValidator(CipherWithDKeyReq.class, List.of("wifiId", "payload"));
    }

    @Bean
    @Qualifier("getCipheredDKeyReqValidator")
    public Validator getCipheredDKeyReqValidator(){
        return new BaseValidator(CipherWithDKeyReq.class, List.of("wifiId"));
    }

    @Bean
    @Qualifier("createProductReqValidator")
    public Validator createProductReqValidator(){
        return new BaseValidator(CreateProductReq.class, List.of("majorDomainId", "subDomainId", "developerId", "departmentId"));
    }

    @Bean
    @Qualifier("createSqlReqValidator")
    public Validator createSqlReqValidator(){
        return new BaseValidator(CreateSqlReq.class, List.of("domainId"));
    }

    @Bean
    @Qualifier("registerDevicesReqValidator")
    public Validator registerDevicesReqValidator(){
        return new BaseValidator(RegisterDevicesReq.class, List.of("domain", "subDomain", "batchCode", "devices"));
    }


    @Bean
    @Qualifier("getKeyPairsReqValidator")
    public Validator getKeyPairsReqValidator(){
        return new BaseValidator(GetKeyPairsReq.class, List.of("developerId"));
    }

    @Bean
    @Qualifier("modifyKeyDescriptionReqValidator")
    public Validator modifyKeyDescriptionReqValidator(){
        return new BaseValidator(ModifyKeyDescriptionReq.class, List.of("developerId", "majorDomainId"));
    }

    @Bean
    @Qualifier("deleteKeyPairReqValidator")
    public Validator deleteKeyPairReqValidator(){
        return new BaseValidator(ModifyKeyDescriptionReq.class, List.of("developerId", "accessKey"));
    }


    @Bean
    @Qualifier("enableKeyPairReqValidator")
    public Validator enableKeyPairReqValidator(){
        return new BaseValidator(EnableKeyPairReq.class, List.of("developerId"));
    }


    @Bean
    @Qualifier("createProjectReqValidator")
    public Validator createProjectReqValidator(){
        return new BaseValidator(CreateProjectReq.class, List.of("developerId", "name"));
    }


    @Bean
    @Qualifier("getDeveloperByMajorDomainIdReqValidator")
    public Validator getDeveloperByMajorDomainIdReqValidator(){
        return new BaseValidator(GetDeveloperByMajorDomainIdReq.class, List.of("majorDomainId"));
    }

    @Bean
    @Qualifier("getInfoReqValidator")
    public Validator getInfoReqValidator(){
        return new BaseValidator(GetInfoReq.class, List.of("majorDomainId", "subDomainId"));
    }

    @Bean
    @Qualifier("authTokenAndBatchReqValidator")
    public Validator authTokenAndBatchReqValidator(){
        return new BaseValidator(AuthTokenAndBatchReq.class, List.of("wifiId", "data"));
    }
}
